package mynet

import (
	"sync"
)

type conManager struct {
	connLock sync.Mutex
	connMap  map[int]IConnection
}

func (this *conManager) Add(connection IConnection) {
	this.connLock.Lock()
	defer this.connLock.Unlock()
	this.connMap[connection.GetConId()] = connection
}
func (this *conManager) Del(conId int) {
	this.connLock.Lock()
	defer this.connLock.Unlock()
	client := this.connMap[conId]
	//client.GetExitChan() <- true
	client.GetWriter().Close()
	delete(this.connMap, conId)
}
func (this *conManager) Find(conId int) {

}

func GetNewConManager() *conManager {
	return &conManager{
		connMap: make(map[int]IConnection),
	}
}
